function searchMax(value, arr) {
    let maxPosition = 0;
    let position = 0;
    for (let i = 0; i < arr.length; i++) {
        let num = arr[i];
        if (arr[i] == value) {
            if (num < 0) {
                num = num -1;
            } else if(num > 0){
                num = num +1;
            }
        }
        position += num;
        maxPosition = Math.max(maxPosition, position);
    }
    console.log(maxPosition);
}
searchMax(-5, [-5, 1, 6, 0 -7])